package com.example.riseofthedefender;

import javax.microedition.khronos.opengles.GL10;

public class Game {
	
	public static Player player;
	public static ParallaxBackground parallaxBackground;
	
	public void init() {
		
		
		player = new Player();
		Bullet.initArrayList(80);
		Ball.initArrayList(350);
		Ground.initArrayList(1);
		Soul.initArrayList(0);
		LoadTextFile.load(GlRenderer.context,R.raw.test);
		for(int i = 0; i < Ball.arrayList.size(); ++i)
			Ball.arrayList.get(i).setPosition((float)(Math.random()*Camera.boundE), (float)(Math.random()*Camera.boundN));
		player.setPosition(GameVar.cWidthH, 100);
		ParallaxBackground.init();
		

	}

	public void update() {
		Camera.update();
		ParallaxBackground.update();
		for(int i = 0; i < Ball.arrayList.size(); ++i)Ball.arrayList.get(i).update();
		for(int i = 0; i < Bullet.arrayList.size(); ++i)Bullet.arrayList.get(i).update();
		player.update();
		SwordThing.update(player.pos);
		GunThing.update(player.pos);
	}

	public void draw(GL10 gl) {
		ParallaxBackground.draw(gl);
		for(int i = 0; i < Ground.arrayList.size(); ++i)Ground.arrayList.get(i).draw(gl);
		for(int i = 0; i < Soul.arrayList.size(); ++i)Soul.arrayList.get(i).draw(gl);
		for(int i = 0; i < Ball.arrayList.size(); ++i)Ball.arrayList.get(i).draw(gl);
		player.draw(gl);
		for(int i = 0; i < Bullet.arrayList.size(); ++i)Bullet.arrayList.get(i).draw(gl);
		SwordThing.draw(gl);
		GunThing.draw(gl);
		LazerThing.draw(gl);
		Camera.drawBounds(gl);
	}

}
